import org.openqa.selenium.By
import org.openqa.selenium.WebDriver
import org.openqa.selenium.chrome.ChromeDriver
import org.openqa.selenium.firefox.FirefoxDriver
import org.openqa.selenium.interactions.Actions

import java.util.concurrent.TimeUnit
/**
 * Created by Lzx on 2017/12/1.
 */
def path = "webdriver/chromedriver.exe"
System.setProperty("webdriver.chrome.driver", path)

WebDriver driver = new ChromeDriver()
driver.manage().window().maximize()
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS)
driver.get("http://weibo.com/")
driver.findElement(By.id("loginname")).sendKeys("0")
driver.findElement(By.name("password")).sendKeys("")
driver.findElement(By.cssSelector(".W_btn_a.btn_32px")).click()
//driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS)
sleep(1000)
driver.findElement(By.xpath("//*[@id=\"v6_pl_rightmod_myinfo\"]/div/div/div[2]/ul/li[1]/a")).click()
sleep(1000)
//driver.manage().timeouts().pageLoadTimeout(5, TimeUnit.SECONDS)
cancelFocuse(driver)

//driver.findElement(By.cssSelector(".btn_link.S_txt1")).click()
//Actions action = new Actions(driver)
//def eles = driver.findElements(By.className("markup_choose"))
//eles.each {
//    action.click(it).perform()
//}
//driver.findElement(By.className("W_btn_a")).click()
//driver.findElement(By.cssSelector(".W_btn_a.btn_34px")).click()

def cancelFocuse(def driver) {
    sleep(1000)
    driver.findElement(By.cssSelector(".btn_link.S_txt1")).click()
    Actions action = new Actions(driver)
    def eles = driver.findElements(By.className("markup_choose"))
    eles.each {
        action.click(it).perform()
    }
    sleep(1000)
    driver.findElement(By.xpath("//*[@id=\"Pl_Official_RelationMyfollow__93\"]/div/div/div/div[1]/div[3]/div[1]/div[2]/div/a[2]")).click()
    sleep(1000)
    driver.findElement(By.cssSelector(".W_btn_a.btn_34px")).click()
    sleep(2000)
    cancelFocuse(driver)
}